%%%-------------------------------------------------------------------
%%% File    : rdf_spalg_SUITE.erl
%%% Author  :  <vjache>
%%% Description : 
%%%
%%% Created :  2 May 2009 by  <vjache>
%%%-------------------------------------------------------------------
-module(rdf_spalg_SUITE).

%% Note: This directive should only be used in test suites.
-compile(export_all).

-include_library("ct.hrl").

%%--------------------------------------------------------------------
%% COMMON TEST CALLBACK FUNCTIONS
%%--------------------------------------------------------------------

%%--------------------------------------------------------------------
%% Function: suite() -> Info
%%
%% Info = [tuple()]
%%   List of key/value pairs.
%%
%% Description: Returns list of tuples to set default properties
%%              for the suite.
%%
%% Note: The suite/0 function is only meant to be used to return
%% default data values, not perform any other operations.
%%--------------------------------------------------------------------
suite() ->
    [{timetrap,{minutes,10}}].

%%--------------------------------------------------------------------
%% Function: init_per_suite(Config0) ->
%%               Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
%%
%% Config0 = Config1 = [tuple()]
%%   A list of key/value pairs, holding the test case configuration.
%% Reason = term()
%%   The reason for skipping the suite.
%%
%% Description: Initialization before the suite.
%%
%% Note: This function is free to add any key/value pairs to the Config
%% variable, but should NOT alter/remove any existing entries.
%%--------------------------------------------------------------------
init_per_suite(Config) ->
    Config.

%%--------------------------------------------------------------------
%% Function: end_per_suite(Config0) -> void() | {save_config,Config1}
%%
%% Config0 = Config1 = [tuple()]
%%   A list of key/value pairs, holding the test case configuration.
%%
%% Description: Cleanup after the suite.
%%--------------------------------------------------------------------
end_per_suite(_Config) ->
    ok.

%%--------------------------------------------------------------------
%% Function: init_per_testcase(TestCase, Config0) ->
%%               Config1 | {skip,Reason} | {skip_and_save,Reason,Config1}
%%
%% TestCase = atom()
%%   Name of the test case that is about to run.
%% Config0 = Config1 = [tuple()]
%%   A list of key/value pairs, holding the test case configuration.
%% Reason = term()
%%   The reason for skipping the test case.
%%
%% Description: Initialization before each test case.
%%
%% Note: This function is free to add any key/value pairs to the Config
%% variable, but should NOT alter/remove any existing entries.
%%--------------------------------------------------------------------
init_per_testcase(_TestCase, Config) ->
    Config.

%%--------------------------------------------------------------------
%% Function: end_per_testcase(TestCase, Config0) ->
%%               void() | {save_config,Config1}
%%
%% TestCase = atom()
%%   Name of the test case that is finished.
%% Config0 = Config1 = [tuple()]
%%   A list of key/value pairs, holding the test case configuration.
%%
%% Description: Cleanup after each test case.
%%--------------------------------------------------------------------
end_per_testcase(_TestCase, _Config) ->
    ok.

%%--------------------------------------------------------------------
%% Function: sequences() -> Sequences
%%
%% Sequences = [{SeqName,TestCases}]
%% SeqName = atom()
%%   Name of a sequence.
%% TestCases = [atom()]
%%   List of test cases that are part of the sequence
%%
%% Description: Specifies test case sequences.
%%--------------------------------------------------------------------
sequences() -> 
    [].

%%--------------------------------------------------------------------
%% Function: all() -> TestCases | {skip,Reason}
%%
%% TestCases = [TestCase | {sequence,SeqName}]
%% TestCase = atom()
%%   Name of a test case.
%% SeqName = atom()
%%   Name of a test case sequence.
%% Reason = term()
%%   The reason for skipping all test cases.
%%
%% Description: Returns the list of test cases that are to be executed.
%%--------------------------------------------------------------------
all() -> 
    [a_test_case].


%%--------------------------------------------------------------------
%% TEST CASES
%%--------------------------------------------------------------------

%%--------------------------------------------------------------------
%% Function: TestCase() -> Info
%%
%% Info = [tuple()]
%%   List of key/value pairs.
%%
%% Description: Test case info function - returns list of tuples to set
%%              properties for the test case.
%%
%% Note: This function is only meant to be used to return a list of
%% values, not perform any other operations.
%%--------------------------------------------------------------------

%%============== SPARQL UC 2.1-a =====================================
%% SELECT ?title 
%% WHERE { <http://example.org/book/book1> <http://purl.org/dc/elements/1.1/title> ?title }
%%====================================================================
sparql_2_1_a() -> 
    [].
sparql_2_1_a(_Config) -> 
	Title=title,
    Pattern={'$bgp',
	 [
	  {{"http://example.org/book/book1"},{"http://purl.org/dc/elements/1.1/title"},Title,'_'}
	 ]
	},
	rdf_spalg:select(Pattern,[Title],pipe_console:new()).
%%============== SPARQL UC 2.5-a =====================================
%% PREFIX  foaf: <http://xmlns.com/foaf/0.1/>
%% SELECT  ?mbox
%% WHERE { ?x foaf:name "Johnny Lee Outlaw" .
%%  		 ?x foaf:mbox ?mbox }
%%====================================================================
sparql_2_5_a() -> 
    [].
sparql_2_5_a(_Config) -> 
	X=x,
	Mbox=mbox,
    Pattern={'$bgp',
	 [
	  {X,{foaf,"name"},{'$lit',"Johnny Lee Outlaw",string},'_'},
	  {X,{foaf,"mbox"},Mbox,'_'}
	 ]
	},
	rdf_spalg:select(Pattern,[Mbox],pipe_console:new()).

%%============== SPARQL UC 2.6-a =====================================
%% PREFIX  foaf: <http://xmlns.com/foaf/0.1/>
%% SELECT  ?name ?mbox
%% WHERE { ?x foaf:name ?name .
%%  		 ?x foaf:mbox ?mbox }
%%====================================================================
sparql_2_6_a() -> 
    [].
sparql_2_6_a(_Config) -> 
	X=x,
	Mbox=mbox,
	Name=name,
    Pattern={'$bgp',
	 [
	  {X,{foaf,"name"},Name,'_'},
	  {X,{foaf,"mbox"},Mbox,'_'}
	 ]
	},
	rdf_spalg:select(Pattern,[Name,Mbox],pipe_console:new()).
%%============== SPARQL UC 2.7-a =====================================
%% PREFIX  foaf: <http://xmlns.com/foaf/0.1/>
%% SELECT  ?x ?name
%% WHERE { ?x foaf:name ?name }
%%====================================================================
sparql_2_7_a() -> 
    [].
sparql_2_7_a(_Config) -> 
	X=x,
	Name=name,
    Pattern={'$bgp',
	 [
	  {X,{foaf,"name"},Name,'_'}
	 ]
	},
	rdf_spalg:select(Pattern,[X,Name],pipe_console:new()).
%%============== SPARQL UC 3.1-a =====================================
%% SELECT ?v WHERE { ?v ?p 42 }
%%====================================================================
sparql_3_1_a() -> 
    [].
sparql_3_1_a(_Config) -> 
	V=v,
	P=p,
    Pattern={'$bgp',
	 [
	  {V,P,{'$lit',42,number},'_'}
	 ]
	},
	rdf_spalg:select(Pattern,[V],pipe_console:new()).
%%============== SPARQL UC 3.1-b =====================================
%% SELECT ?v 
%% WHERE { 
%% 	?v ?p "abc"^^<http://example.org/datatype#specialDatatype> }
%%====================================================================
sparql_3_1_b() -> 
    [].
sparql_3_1_b(_Config) -> 
	V=v,
	P=p,
    Pattern={'$bgp',
	 [
	  {V,P,{'$lit',"abc",'http://example.org/datatype#specialDatatype'},'_'}
	 ]
	},
	rdf_spalg:select(Pattern,[V],pipe_console:new()).
%%============== SPARQL UC 3.1-d =====================================
%% SELECT ?v WHERE { ?v ?p "cat"@en }
%%====================================================================
sparql_3_1_d() -> 
    [].
sparql_3_1_d(_Config) -> 
	V=v,
	P=p,
    Pattern={'$bgp',
	 [
	  {V,P,{'$lit_lang',"abc",'en'},'_'}
	 ]
	},
	rdf_spalg:select(Pattern,[V],pipe_console:new()).
%%============== SPARQL UC 3.2-a =====================================
%% PREFIX 		dc:		<http://purl.org/dc/elements/1.1/>
%% PREFIX		ns:		<http://example.org/ns#>
%% SELECT ?title ?price
%% WHERE { ?x	ns:price ?price .
%% 		FILTER (?price < 30) .
%% 		?x dc:title ?title . }
%%====================================================================
sparql_3_2_a() -> 
    [].
sparql_3_2_a(_Config) -> 
	X=x,
	Price=price,
	Title=title,
    Bgp={'$bgp',
	 [
	  {X,{ns,"price"},Price,'_'},
	  {X,{dc,"title"},Title,'_'}
	 ]
	},
	Pattern={'$filter',Bgp,{'$ls',Price,{'$lit',30,number}}},
	rdf_spalg:select(Pattern,[Title,Price],pipe_console:new()).
sparql_3_2_a_b() -> 
    [].
sparql_3_2_a_b(_Config) -> 
	X=x,
	Price=price,
	Title=title,
    Bgp={'$bgp',
	 [
	  {X,{ns,"price"},Price,'_'},
	  {X,{dc,"title"},Title,'_'}
	 ]
	},
	Pattern={'$filter',Bgp,{'$ls',Price,30}},
	rdf_spalg:select(Pattern,[Title,Price],pipe_console:new()).
%%============== SPARQL UC 5.1-a =====================================
%% PREFIX  foaf: <http://xmlns.com/foaf/0.1/>
%% SELECT  ?name ?mbox
%% WHERE { ?x foaf:name ?name .
%%  		 OPTIONAL {?x foaf:mbox ?mbox }
%%  		}
%%====================================================================
sparql_5_1_a() -> 
    [].
sparql_5_1_a(_Config) -> 
	X=x,
	Mbox=mbox,
	Name=name,
    Bgp1={'$bgp',
	 [
	  {X,{foaf,"name"},Name,'_'}
	 ]
	},
    Bgp2={'$bgp',
	 [
	  {X,{foaf,"mbox"},Mbox,'_'}
	 ]
	},
	Pattern={'$ljoin',Bgp1,[Bgp2]},
	rdf_spalg:select(Pattern,[Name,Mbox],pipe_console:new()).
%%============== SPARQL UC 5.2-a-m ===================================
%% PREFIX 		dc:		<http://purl.org/dc/elements/1.1/>
%% PREFIX		ns:		<http://example.org/ns#>
%% SELECT ?title ?price
%% WHERE { 
%% 			?x dc:title ?title .
%% 			OPTIONAL {?x	ns:price ?price .
%% 				FILTER (?price < 30)
%% 			}
%% }
%%====================================================================
sparql_5_2_a() -> 
    [].
sparql_5_2_a(_Config) -> 
	X=x,
	Title=title,
	Price=price,
    Bgp1={'$bgp',
	 [
	  {X,{dc,"title"},Title,'_'}
	 ]
	},
    Bgp2={'$bgp',
	 [
	  {X,{ns,"price"},Price,'_'}
	 ]
	},
	Filter={'$filter',Bgp2,{'$ls',Price,{'$lit',30,number}}},
	Pattern={'$ljoin',Bgp1,[Filter]},
	rdf_spalg:select(Pattern,[Title,Price],pipe_console:new()).
%%============== SPARQL UC 5.3-a =====================================
%% PREFIX  foaf: <http://xmlns.com/foaf/0.1/>
%% SELECT  ?name ?mbox ?hpage
%% WHERE { ?x foaf:name ?name .
%%  		 OPTIONAL {?x foaf:mbox ?mbox }
%%  		 OPTIONAL {?x foaf:homepage ?hpage }
%%  		}
%%====================================================================
sparql_5_3_a() -> 
    [].
sparql_5_3_a(_Config) -> 
	X=x,
	Mbox=mbox,
	Name=name,
	Hpage=hpage,
    Bgp1={'$bgp',
	 [
	  {X,{foaf,"name"},Name,'_'}
	 ]
	},
    Bgp2={'$bgp',
	 [
	  {X,{foaf,"mbox"},Mbox,'_'}
	 ]
	},
    Bgp3={'$bgp',
	 [
	  {X,{foaf,"homepage"},Hpage,'_'}
	 ]
	},
	Pattern={'$ljoin',Bgp1,[Bgp2,Bgp3]},
	rdf_spalg:select(Pattern,[Name,Mbox,Hpage],pipe_console:new()).
%%============== SPARQL UC 5.5-a =====================================
%% PREFIX foaf:   	<http://xmlns.com/foaf/0.1/>
%% PREFIX vcard:	<http://w3.org/2001/vcard-rdf/3.0#>
%% 
%% SELECT ?foafName ?mbox ?gname ?fname
%% 	WHERE {
%% 				?x foaf:name ?foafName .
%% 				OPTIONAL { ?x foaf:mbox ?mbox } .
%% 				OPTIONAL { ?x vcard:N ?vc .
%% 							?vc vcard:Given ?gname .
%% 							OPTIONAL { ?vc vcard:Family ?fname }
%% 						}
%% 			}
%%====================================================================
sparql_5_5_a() -> 
    [].
sparql_5_5_a(_Config) -> 
	X=x,
	Vc=vc,
	FoafName=foafName,
	Mbox=mbox,
	Fname=fname,
	Gname=gname,
    Bgp1={'$bgp',
	 [
	  {X,{foaf,"name"},FoafName,'_'}
	 ]
	},
    Bgp2={'$bgp',
	 [
	  {X,{vcard,"N"},Vc,'_'},
	  {X,{vcard,"Given"},Gname,'_'}
	 ]
	},
    Bgp3={'$bgp',
	 [
	  {Vc,{vcard,"Family"},Fname,'_'}
	 ]
	},
	Ljoin={'$ljoin',Bgp2,Bgp3},
	Pattern={'$ljoin',Bgp1,[Ljoin]},
	rdf_spalg:select(Pattern,[FoafName,Mbox,Gname,Fname],pipe_console:new()).
%%============== SPARQL UC 8.1-a =====================================
%% PREFIX foaf: <http://xmlns.com/foaf/0.1/>
%% 
%% SELECT ?src ?bobNick
%% WHERE
%%   {
%%     GRAPH ?src
%%     { ?x foaf:mbox <mailto:bob@work.example> .
%%       ?x foaf:nick ?bobNick
%%     }
%%   }
%%====================================================================
sparql_8_1_a() -> 
    [].
sparql_8_1_a(_Config) -> 
	X=x,
	Src=src,
	BobNick=bobNick,
    Pattern={'$bgp',
	 [
	  {X,{foaf,"mbox"},{"mailto:bob@work.example"},Src},
	  {X,{foaf,"nick"},BobNick,Src}
	 ]},
	rdf_spalg:select(Pattern,[Src,BobNick],pipe_console:new()).
%%============== SPARQL UC 8.2-a =====================================
%% PREFIX foaf: <http://xmlns.com/foaf/0.1/>
%% PREFIX data: <http://example.org/foaf/>
%% 
%% SELECT ?nick
%% WHERE
%%   {
%%     GRAPH data:bobFoaf
%%     { ?x foaf:mbox <mailto:bob@work.example> .
%%       ?x foaf:nick ?nick
%%     }
%%   }
%%====================================================================
sparql_8_2_a() -> 
    [].
sparql_8_2_a(_Config) -> 
	X=x,
	Src={data,"bobFoaf"},
	Nick=nick,
    Pattern={'$bgp',
	 [
	  {X,{foaf,"mbox"},{"mailto:bob@work.example"},Src},
	  {X,{foaf,"nick"},Nick,Src}
	 ]},
	rdf_spalg:select(Pattern,[Src,Nick],pipe_console:new()).
%%============== SPARQL UC 8.3-a =====================================
%% PREFIX  data:  <http://example.org/foaf/>
%% PREFIX  foaf:  <http://xmlns.com/foaf/0.1/>
%% PREFIX  rdf:   <http://www.w3.org/1999/02/22-rdf-syntax-ns#> 
%% PREFIX  rdfs:  <http://www.w3.org/2000/01/rdf-schema#>
%% 
%% SELECT ?mbox ?nick ?ppd
%% WHERE
%% {
%%   GRAPH data:aliceFoaf
%%   {
%%     ?alice foaf:mbox <mailto:alice@work.example> ;
%%            foaf:knows ?whom .
%%     ?whom  foaf:mbox ?mbox ;
%%            rdfs:seeAlso ?ppd .
%%     ?ppd  a foaf:PersonalProfileDocument .
%%   } .
%%   GRAPH ?ppd
%%   {
%%       ?w foaf:mbox ?mbox ;
%%          foaf:nick ?nick 
%%   }
%% }
%%====================================================================
sparql_8_3_a() -> 
    [].
sparql_8_3_a(_Config) -> 
	W=w,
	Alice=alice,
	AliceFoaf={data,"aliceFoaf"},
	Whom=whom,
	Ppd=ppd,
	Nick=nick,
	Mbox=mbox,
    Pattern={'$bgp',
	 [
	  {Alice,{foaf,"mbox"},{"mailto:alice@work.example"},AliceFoaf},
	  {Alice,{foaf,"knows"},Whom,AliceFoaf},
	  {Whom,{foaf,"mbox"},Mbox,AliceFoaf},
	  {Whom,{rdfs,"seeAlso"},Ppd,AliceFoaf},
	  {Ppd,{rdf,"type"},{foaf,"PersonalProfileDocument"},AliceFoaf},
	  {W,{foaf,"mbox"},Mbox,Ppd},
	  {W,{foaf,"nick"},Nick,Ppd}
	 ]},
	rdf_spalg:select(Pattern,[Mbox,Nick,Ppd],pipe_console:new()).

%%============== SPARQL UC 10.2-a ====================================
%% PREFIX foaf:    <http://xmlns.com/foaf/0.1/>
%% SELECT ?nameX ?nameY ?nickY
%% WHERE
%%   { ?x foaf:knows ?y ;
%%        foaf:name ?nameX .
%%     ?y foaf:name ?nameY .
%%     OPTIONAL { ?y foaf:nick ?nickY } 
%%   }
%%====================================================================
sparql_10_2_a() -> 
    [].
sparql_10_2_a(_Config) -> 
	X=x,
	Y=y,
	NameX=nameX,
	NameY=nameY,
	NickY=nickY,
    Bgp1={'$bgp',
	 [
	  {X,{foaf,"knows"},Y,'_'},
	  {X,{foaf,"name"},NameX,'_'},
	  {Y,{foaf,"name"},NameY,'_'}
	 ]},
    Bgp2={'$bgp',
	 [
	  {Y,{foaf,"nick"},NickY,'_'}
	 ]},
	Pattern={'$ljoin',Bgp1,[Bgp2]},
	rdf_spalg:select(Pattern,[NameX, NameY, NickY],pipe_console:new()).

%%============== SPARQL UC 11.2.3.1-a ================================
%% PREFIX foaf: <http://xmlns.com/foaf/0.1/>
%% SELECT ?name1 ?name2
%%  WHERE { ?x foaf:name  ?name1 ;
%%             foaf:mbox  ?mbox1 .
%%          ?y foaf:name  ?name2 ;
%%             foaf:mbox  ?mbox2 .
%%          FILTER (?mbox1 = ?mbox2 && ?name1 != ?name2)
%%        }
%%====================================================================
sparql_11_2_3_1_a() -> 
    [].
sparql_11_2_3_1_a(_Config) -> 
	X=x,
	Y=y,
	Name1=name1,
	Name2=name2,
	Mbox1=mbox1,
	Mbox2=mbox2,
    Bgp={'$bgp',
	 [
	  {X,{foaf,"name"},Name1,'_'},
	  {X,{foaf,"mbox"},Mbox1,'_'},
	  {Y,{foaf,"name"},Name2,'_'},
	  {Y,{foaf,"mbox"},Mbox2,'_'}
	 ]},
	Pattern={'$filter',Bgp,{'$and',[{'$eq',Mbox1,Mbox2},{'$ne',Name1,Name2}]}},
	rdf_spalg:select(Pattern,[Name1, Name2],pipe_console:new()).

%%============== SPARQL UC 11.2.3.1-b ================================
%% PREFIX a:      <http://www.w3.org/2000/10/annotation-ns#>
%% PREFIX dc:     <http://purl.org/dc/elements/1.1/>
%% PREFIX xsd:    <http://www.w3.org/2001/XMLSchema#>
%% 
%% SELECT ?annotates
%% WHERE { ?annot  a:annotates  ?annotates .
%%         ?annot  dc:date      ?date .
%%         FILTER ( ?date = xsd:dateTime("2004-01-01T00:00:00Z") || 
%% 				 ?date = xsd:dateTime("2005-01-01T00:00:00Z") ) }
%%====================================================================
sparql_11_2_3_1_b() -> 
    [].
sparql_11_2_3_1_b(_Config) -> 
	Annotates=annotates,
	Annot=annot,
	Date=date,
    Bgp={'$bgp',
	 [
	  {Annot,{a,"annotates"},Annotates,'_'},
	  {Annot,{dc,"date"},Date,'_'}
	 ]},
	Pattern={'$filter',Bgp,{'$or',[{'$eq',Date,{{2004,1,1},{0,0,0}}},{'$eg',Date,{{2005,1,1},{0,0,0}}}]}},
	rdf_spalg:select(Pattern,[Annotates],pipe_console:new()).

%%============== SPARQL UC 11.2.3.2-a ================================
%% PREFIX foaf: <http://xmlns.com/foaf/0.1/>
%% PREFIX dc:   <http://purl.org/dc/elements/1.1/>
%% PREFIX xsd:   <http://www.w3.org/2001/XMLSchema#>
%% SELECT ?name
%%  WHERE { ?x foaf:givenName  ?name .
%%          OPTIONAL { ?x dc:date ?date } .
%%          FILTER (bound(?date)) }
%%====================================================================
sparql_11_2_3_2_a() -> 
    [].
sparql_11_2_3_2_a(_Config) -> 
	X=x,
	Name=name,
	Date=date,
    Q1={'$qp',X,{foaf,"givenName"},Name,'_'},
    Q2={'$qp',X,{dc,"date"},Date,'_'},
	LJoin={'$ljoin',Q1,[Q2]},
	Pattern={'$filter',LJoin,{'$bound',Date}},
	rdf_spalg:select(Pattern,[Name],pipe_console:new()).
%%============== SPARQL UC 11.2.3.2-b ================================
%% PREFIX foaf: <http://xmlns.com/foaf/0.1/>
%% PREFIX dc:   <http://purl.org/dc/elements/1.1/>
%% SELECT ?name
%%  WHERE { ?x foaf:givenName  ?name .
%%          OPTIONAL { ?x dc:date ?date } .
%%          FILTER (!bound(?date)) }
%%====================================================================
sparql_11_2_3_2_b() -> 
    [].
sparql_11_2_3_2_b(_Config) -> 
	X=x,
	Name=name,
	Date=date,
    Q1={'$qp',X,{foaf,"givenName"},Name,'_'},
    Q2={'$qp',X,{dc,"date"},Date,'_'},
	LJoin={'$ljoin',Q1,[Q2]},
	Pattern={'$filter',LJoin,{'$not',{'$bound',Date}}},
	rdf_spalg:select(Pattern,[Name],pipe_console:new()).
%%============== SPARQL UC 11.2.3.3-a ================================
%% PREFIX foaf: <http://xmlns.com/foaf/0.1/>
%% SELECT ?name ?mbox
%%  WHERE { ?x foaf:name  ?name ;
%%             foaf:mbox  ?mbox .
%%          FILTER isUri(?mbox) }
%%====================================================================
sparql_11_2_3_3_a() -> 
    [].
sparql_11_2_3_3_a(_Config) -> 
	X=x,
	Name=name,
	Mbox=mbox,
    Bgp={'$bgp',
		 [
		  {X,{foaf,"name"},Name,'_'},
		  {X,{foaf,"mbox"},Mbox,'_'}
		 ]},
	Pattern={'$filter',Bgp,{'$isUri',Mbox}},
	rdf_spalg:select(Pattern,[Name,Mbox],pipe_console:new()).
%%============== SPARQL UC 11-a ======================================
%% PREFIX a:      <http://www.w3.org/2000/10/annotation-ns#>
%% PREFIX dc:     <http://purl.org/dc/elements/1.1/>
%% PREFIX xsd:    <http://www.w3.org/2001/XMLSchema#>
%% 
%% SELECT ?annot
%% WHERE { ?annot  a:annotates  <http://www.w3.org/TR/rdf-sparql-query/> .
%%         ?annot  dc:date      ?date .
%%         FILTER ( ?date < "2005-01-01T00:00:00Z"^^xsd:dateTime ) }
%%====================================================================
sparql_11_a() -> 
    [].
sparql_11_a(_Config) -> 
	Annot=annot,
	Date=date,
    Bgp={'$bgp',
	 [
	  {Annot,{a,"annotates"},{"http://www.w3.org/TR/rdf-sparql-query/"},'_'},
	  {Annot,{dc,"date"},Date,'_'}
	 ]},
	Pattern={'$filter',Bgp,{'$ls',
							Date,
							{{2005,1,1},{0,0,0}}
						   }},
	rdf_spalg:select(Pattern,[Annot],pipe_console:new()).
%%============== SPARQL UC 11-b ======================================
%% PREFIX a:      <http://www.w3.org/2000/10/annotation-ns#>
%% PREFIX dc:     <http://purl.org/dc/elements/1.1/>
%% PREFIX xsd:    <http://www.w3.org/2001/XMLSchema#>
%% 
%% SELECT ?annot
%% WHERE { ?annot  a:annotates  <http://www.w3.org/TR/rdf-sparql-query/> .
%%         ?annot  dc:date      ?date .
%%         FILTER ( xsd:dateTime(?date) > "2005-01-01T00:00:00Z"^^xsd:dateTime ) }
%%====================================================================
sparql_11_b() -> 
    [].
sparql_11_b(_Config) -> 
	Annot=annot,
	Date=date,
    Bgp={'$bgp',
	 [
	  {Annot,{a,"annotates"},{"http://www.w3.org/TR/rdf-sparql-query/"},'_'},
	  {Annot,{dc,"date"},Date,'_'}
	 ]},
	Pattern={'$filter',Bgp,{'$gr',
							{'$fn',dateTime,Date},
							{{2005,1,1},{0,0,0}}
						   }},
	rdf_spalg:select(Pattern,[Annot],pipe_console:new()).


